﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="markupmain.aspx.cs" Inherits="IGIS.Extensions.markup.markupmain" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html>
<head>
	<title>Manage Markups</title>
    <link rel="stylesheet" href="../../styles/gt.css" type="text/css">
	
	<script language="javascript">
        var session = '<%= _sesseion %>';
        var mapName = '<%= _mapName %>';

		var CMD_NEW 	= 1;
		var CMD_OPEN	= 2;
		var CMD_DELETE	= 3;
		var CMD_REFRESH	= 4;;
		var CMD_EDIT	= 5;
		var CMD_CLOSE	= 6;
			
		function SubmitCommand(cmd)
		{
            var commandInput = document.getElementById("commandInput");
			commandInput.value = cmd;

            var markupForm = document.getElementById("markupForm");
			if (cmd == CMD_NEW)
				markupForm.action = "newmarkup.aspx";
			else if (cmd == CMD_EDIT)
				markupForm.action = "editmarkup.aspx";
			else
				markupForm.action = "markupmain.aspx";
		    if(cmd == CMD_DELETE)
		    {
		      if(!confirm("השיכבה תמחק. להמשיך?")) return;

		    }
			markupForm.submit();
		}
		
		function OnAvailableMarkupChange()
		{
            var availableSelect = document.getElementById("availableMarkup");
			var openBtn = document.getElementById("openBtn");
			var deleteBtn = document.getElementById("deleteBtn");
			
			if (availableSelect.selectedIndex >= 0)
			{
				openBtn.disabled = false;
				deleteBtn.disabled = false;
			}
			else
			{
				openBtn.disabled = true;
				deleteBtn.disabled = true;
			}
		} 

		function OnOpenMarkupChange()
		{
            var openSelect = document.getElementById("openMarkup");
			var editBtn = document.getElementById("editBtn");
			var closeBtn = document.getElementById("closeBtn");
			
			if (openSelect.selectedIndex >= 0)
			{
				editBtn.disabled = false;
				closeBtn.disabled = false;
			}
			else
			{
				editBtn.disabled = true;
				closeBtn.disabled = true;
			}
		} 
		
		function OnLoad()
		{
			OnAvailableMarkupChange();
			OnOpenMarkupChange();
		
		<% if (refreshMap) { %>
			parent.parent.Refresh();
		<% } %>
		}
    </script>
	
</head>

<body dir=rtl onLoad="OnLoad()" style="margin:5px">

<% if (errorMsg == null) { %>

<form action="" method="post" enctype="application/x-www-form-urlencoded" id="markupForm" target="_self">
<table class="RegText" border="0" cellspacing="0" width="100%">
	<tr><td class="Title">ניהול שכבות<hr></td></tr>
	<tr><td class="SubTitle">רשימת שכבות נוכחית</td></tr>
	<tr>
		<td class="RegText">
			<select dir=rtl name="MARKUPLAYER" size="15" class="Ctrl" id="availableMarkup" onChange="OnAvailableMarkupChange()" style="width: 100%">
				<%
                    String selected = "selected";
                    foreach (String markupResId in availableMarkup.Keys)
                    {
                        String markupName = (String)availableMarkup[markupResId];
				%>
				<option value="<%= markupResId %>" <%=selected %> ><%= markupName%></option> 
				<%
                        selected = "";
                    }
				%>
		  	</select>
		</td>
	</tr>
	<tr>
		<td>
		    <asp:Literal ID="UnSuccessText" runat="server" Visible="false"></asp:Literal>
			<input class="Ctrl" type="button" id="newBtn" onClick="SubmitCommand(CMD_NEW)" value="חדש" style="width:40px">
			<input class="Ctrl" type="button" id="openBtn" onClick="SubmitCommand(CMD_OPEN)" value="הצג" style="width:40px">
			<input class="Ctrl" type="button" id="deleteBtn" onClick="SubmitCommand(CMD_DELETE)" value="מחק" style="width:40px">
			<input class="Ctrl" type="button" id="refreshBtn" onClick="SubmitCommand(CMD_REFRESH)" value="רענן" style="width:40px">
			<br><br>
		</td>
	</tr>
	<tr><td class="SubTitle">רשימת שכבות מוצגת</td></tr>
	<tr>
		<td class="RegText">
			<select name="OPENMARKUP" size="10" class="Ctrl" id="openMarkup" onChange="OnOpenMarkupChange()" style="width: 100%">
				<%
                    selected = "selected";
                    foreach (String markupLayer in openMarkup.Keys)
                    {
                        String markupName = (String)openMarkup[markupLayer];
				%>
				<option value="<%= markupLayer %>" <%=selected %> ><%= markupName%></option> 
				<%
                        selected = "";
                    }
				%>
		  	</select>
		</td>
	</tr>
	<tr>
		<td>
			<input class="Ctrl" type="button" id="editBtn" onClick="SubmitCommand(CMD_EDIT)" value="עדכן" style="width:40px">
			<input class="Ctrl" type="button" id="closeBtn" onClick="SubmitCommand(CMD_CLOSE)" value="סגור" style="width:40px">
			<br><br>
		</td>
	</tr>	
</table>
<input name="SESSION" type="hidden" value="<%= GetParameter(args, "SESSION") %>">
<input name="MAPNAME" type="hidden" value="<%= GetParameter(args, "MAPNAME") %>">
<input name="LAYOUT" type="hidden" value="<%= GetParameter(args, "LAYOUT") %>">
<input name="MARKUPCOMMAND" type="hidden" value="" id="commandInput">
</form>

<% } else { %>

<table class="RegText" border="0" cellspacing="0" width="100%%">
	<tr><td class="Title">Error<hr></td></tr>
	<tr><td><%= errorMsg %></td></tr>
	<tr><td><%= errorDetail %></td></tr>
</table>

<% } %>

</body>

</html>

